// 获取全局 app 实例
const app = getApp();

const basicContainers = [
  {
    name: '画师信息',
    thumb: '/image/icon/view.png',
    nameEn: '',
    path: '/pages/message/message',
  }
];
const Containers= [
  {
    name: '画师信息',
    thumb: '/image/icon/view.png',
    nameEn: '',
    path: '/pages/message/message',
  },
  {
    name: '画稿明细',
    thumb: '/image/icon/scroll-view.png',
    nameEn: '',
    path: '/pages/receipt/receipt',
  },
  {
    name: '统计总额',
    thumb: '/image/icon/swiper.png',
    nameEn: '',
    path: '/pages/total/total',
  }
]


Page({
  // 声明页面数据
  data: {
    tabs: ['基础组件'],
    activeTab: 0, 
    basicContainers,
    titleOpacity: 1,
    shadow: false,
    user:{}
  },
  // 监听生命周期回调 onLoad
  onLoad() {
  
    // 获取用户信息并存储数据
    app.getUserInfo().then(
      user => {
        this.setData({
          'user.avatar':user.avatar,
          'user.nickName':user.nickName
        });
      },
      () => {
        // 获取用户信息失败
      }
    );
    
  },
  onShow(){
    //判断是否登录
    let token = my.getStorageSync({ key: 'token' });
    if(token.data == null){
      this.setData({
        'basicContainers':basicContainers
      });
      
    }else{
      this.setData({
        'basicContainers':Containers
      });
    }    
  },
  login(){
    my.navigateTo({
    url: "/pages/common/login/login"
  })
  }
    
  
});
